package com.tencent.welink.api.video;

import com.tencent.welink.api.OpenApiTokenChange;
import com.tencent.welink.api.base.WelinkOpenApi;
import com.tencent.welink.config.BussinessConfig;
import com.tencent.welink.util.CrontabUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

/**
 * desc: 监控信息上报
 * Created by junchihe on 2020/6/4.
 */
public class AddMonitor extends WelinkOpenApi {
    private static final Logger log = LogManager.getLogger(AddMonitor.class);

    public AddMonitor() {
        super("/monitor/addMonitor", false);
    }

    @Override
    public void displayResult(String result) {

    }

    /**
     *请求参数	参数类型	是否必填	参数说明
     monitorType	String	是	监控类型：API_MONITOR，VIDEO_PUSH, RPC_MONITOR, WEILINK_API, WEB_API,APP_DATA_MONITOR
     monitorTime	String	是	监控时间点
     serviceName	String	是	服务名称
     accessTime	String	是	访问时间
     result	String	否	监控对象访问结果
     fromIp	String	否	监控对象调用来源
     projectId	String	是	项目ID
     appId	String	是	应用ID
     useTime	String	否	监控对象调用耗时，单位ms
     targetIp	String	否 监控对象执行ip
     din	String	否 设备din
     reportIp	String	否 上报监控的ip


     [
     {
     "accessTime": "201902121335",
     "appId": "",
     "din": "",
     "fromIp": "127.0.0.1",
     "monitorTime": "201902121335",
     "monitorType": "API_MONITOR",
     "projectId": "1",
     "reportIp": "127.0.0.1",
     "result": "1",
     "serviceName": "addMonitor",
     "status": "",
     "targetIp": "127.0.0.1",
     "useTime": "122"
     }
     ]
     *
     * @param args
     */

    public static void main(String[] args) {
        new BussinessConfig();
        CrontabUtil.addTaskInRate(new OpenApiTokenChange(), BussinessConfig.loginDurationMinutes, true);
        AddMonitor addMonitor = new AddMonitor();
        Map<String, Object> map = addMonitor.getExtendsPara();

        map.put("accessTime", "201902121335");
        map.put("appId", "");
        map.put("din", "");
        map.put("fromIp", "127.0.0.1");
        map.put("monitorTime", "201902121335");
        map.put("monitorType", "API_MONITOR");
        map.put("projectId", "1");
        map.put("reportIp", "127.0.0.1");
        map.put("result", "1");
        map.put("serviceName", "addMonitor");
        map.put("status", "");
        map.put("targetIp", "127.0.0.1");
        map.put("useTime", "122");

        addMonitor.DoHttp();
        CrontabUtil.shutdown();
    }
}